home *** CD-ROM | disk | FTP | other *** search
- Path: colossus.holonet.net!russell
- From: russell@news.mdli.com (Russell Blackadar)
- Newsgroups: comp.lang.c++
- Subject: Re: What is wrong with this code?
- Date: 18 Mar 1996 19:57:58 GMT
- Organization: HoloNet National Internet Access System: 510-704-1058/modem
- Message-ID: <4ikf86$8tr@colossus.holonet.net>
- References: <4il0pn$fp@news1.io.org>
- NNTP-Posting-Host: jubal.mdli.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Ivan (ticica@io.org) wrote:
-
- > Please, can someone tell me what's wrong with this program? It's driving
- > me nuts. When I compile it with Borland C++ 3.1 I get null pointer
- > assignment. With Watcom C++ 9.5 the last line (cout << a * 3) prints some
- > junk. Thanks in advance.
-
- [Code deleted]
-
- I believe your main problem (there may be others) is that you have no
- copy constructor. In your operator*, the vecret object is destroyed
- at exit, and its data deleted; but the returned vector (by virtue of
- the compiler-generated copy ctor) contains a copy of the data pointer
- that still references the deleted data.
- --
- Russell Blackadar, russell@mdli.com
-